feat(projects): Load project stats with react query, remove ProjectsStatsStore#115463
Merged
Conversation
Project cards were still going through the old Reflux stats store and mutating project-shaped data with endpoint-expanded stats fields. Move the dashboard over to useAggregatedQueryKeys, keep stats separate from the base Project type, and let the project card read stats through the new hook. Co-Authored-By: Codex <noreply@openai.com>
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.53% |
Project cards could flash back to loading after being unmounted for a bit because the aggregate hook only reduced cached responses for the local ids it had already buffered. Allow callers to synchronously read cached aggregate data for a specific id before queueing another request, so scrolling back to a project card keeps the stats around. Co-Authored-By: Codex <noreply@openai.com>
scttcper
commented
May 13, 2026
| }; | ||
|
|
||
| export function ProjectStatsGraph({project, stats}: Props) { | ||
| stats = stats || project.stats || []; |
The customer details test hits the projects endpoint with statsPeriod=30d, but the shared getsentry project fixture no longer carries stats by default. Keep stats out of the base fixture and add the endpoint-expanded field at the mock response instead. Co-Authored-By: Codex <noreply@openai.com>
# Conflicts: # static/app/types/project.tsx
ryan953
reviewed
May 15, 2026
| ], | ||
| }); | ||
|
|
||
| const {result, unmount} = renderHook( |
Member
There was a problem hiding this comment.
you might want like renderHookWithProviders
and damnit, now i want to go back over all that again and merge it this time.
ryan953
reviewed
May 15, 2026
Comment on lines
+26
to
+28
| afterEach(() => { | ||
| MockApiClient.clearMockResponses(); | ||
| }); |
Member
There was a problem hiding this comment.
this happenes automatically eh?
ryan953
reviewed
May 15, 2026
Comment on lines
+58
to
+59
| const projectStats = getProjectStats(simpleProject); | ||
| const {stats, transactionStats, sessionStats, latestDeploys} = projectStats; |
Member
There was a problem hiding this comment.
Suggested change
| const projectStats = getProjectStats(simpleProject); | |
| const {stats, transactionStats, sessionStats, latestDeploys} = projectStats; | |
| const {stats, transactionStats, sessionStats, latestDeploys} = getProjectStats(simpleProject); |
fighting the bots here...
ryan953
reviewed
May 15, 2026
Comment on lines
+108
to
+127
| const getOne = useCallback( | ||
| (project: Project): ProjectStatsData => { | ||
| const initialStats = getStatsData(project); | ||
| const cachedStats = projectStats.read([project.id])?.[project.id]; | ||
|
|
||
| if (cachedStats && hasStats(cachedStats, hasPerformance)) { | ||
| return cachedStats; | ||
| } | ||
|
|
||
| if (!hasStats(initialStats, hasPerformance)) { | ||
| projectStats.buffer([project.id]); | ||
| } | ||
|
|
||
| return projectStats.data?.[project.id] ?? initialStats; | ||
| }, | ||
| [hasPerformance, projectStats] | ||
| ); | ||
|
|
||
| return useMemo(() => ({getOne}), [getOne]); | ||
| } |
Member
There was a problem hiding this comment.
This might be something to port into feedback
over there we have:
const getOne = useCallback(
(id: string) => {
cache.buffer([id]);
return cache.data?.[id];
},
[cache]
);
just reading from the buffer (which is the last queued set of ids). What we could do in feedback is call cache.read([id]) first, to get existing data, and then call buffer after if needed.
ryan953
approved these changes
May 15, 2026
remove the extra mock cleanup, simplify the remount test, and apply the small destructuring nit from review. Co-Authored-By: Codex GPT-5 <noreply@openai.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kills the ProjectsStatsStore. Mostly used on the /projects/ page. Allows us to remove some types from the global project object that typically don't exist via the ProjectsStore.